-
Notifications
You must be signed in to change notification settings - Fork 545
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: moving dev dependency to main dependency due to upgrade to ts 4 #460
Conversation
Which installation are you referring here? I tried |
If you have a project which depends on This is not a common use-case, but it is at least the case for the |
@@ -60,6 +59,7 @@ | |||
"@opentelemetry/instrumentation": "^0.19.0", | |||
"@opentelemetry/resources": "^0.19.0", | |||
"@opentelemetry/semantic-conventions": "^0.19.0", | |||
"@opentelemetry/tracing": "^0.19.0" | |||
"@opentelemetry/tracing": "^0.19.0", | |||
"@types/aws-lambda": "8.10.76" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually we don't pin dependencies, only dev-dependencies
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just moved them to different location, don't want to change them in any other way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we actually do pin all deps that aren't @opentelemetry
deps usually iirc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only dependency I found is semver e.g. here which is not pinned.
We should be careful which version we use for type definitions. If npm is not able to de-duplicate them users end up in having two versions of e.g. @types/aws-lambda in the same project which usually not what someone wants.
I doubt that typescript is able to use version A for one file and version B for other files. And clearly types will differ between versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might want to think about using *
if that is the case.
In this case, I think it's probably ok since we don't "leak" any of the types from the packages we wrap. If we use @types/pg@1
and the user has @types/pg@2
, ours will simply be installed in the deep node_modules directory at something like node_modules/@opentelemetry/instrumentation-pg/node_modules/@types/pg
no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hard to tell without trying.
Main question is what is typescript using - and remembering - when transpiling a file like this and the user has @types/pg installed in a significant different version then @opentelemetry/instrumentation-pg.
import * from "pg"
import * from "@opentelemetry/instrumentation-pg"
I assume as long as the only types used are protected init(): (InstrumentationNodeModuleDefinition<typeof pgTypes> | InstrumentationNodeModuleDefinition<typeof pgPoolTypes>)[];
in an protected method never used by end users it's don't care.
Once there are APIs using more types it may get problematic.
maybe we should somehow hide/remove the types from InstrumentationAbstract#init
to avoid this at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guys you are aware that because we upgraded to ts 4 now all the packages doesn't contain the types and if you don't install the package by yrself it cannot be used. This change is just fixing to how it was, should be already merged and released. Then we can discuss about all other things but currently the packages are broken especially the meta package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@obecny is right. this simple program fails to compile because of missing types currently:
import type {} from '@opentelemetry/auto-instrumentations-node';
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A simple local test seems to show that typescript correctly differentiates the types. I manually installed @types/pg
under node_modules/@opentelemetry/instrumentation-pg/node_modules/@types/pg
and installed it also at node_modules/@types/pg
. I made a breaking incompatible change to the types manually to the node_modules/@types/pg
. My program still compiled successfuly and didn't break the checks for node_modules/@opentelemetry/instrumentation-pg
so I think @Flarna's version concerns are OK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would that be a different if you keep types in dev and compile using ts 3.x ? you would still break it exactly the same ?. The files will be in the same location if you either keep in dev with ts3 or move it to main packages and compile with ver. 4. You will have exactly the same pinned version of types right ?
Codecov Report
@@ Coverage Diff @@
## main #460 +/- ##
=======================================
Coverage 95.24% 95.24%
=======================================
Files 133 133
Lines 8252 8252
Branches 810 810
=======================================
Hits 7860 7860
Misses 392 392 |
I can't figure out why this is caused. My first thought was that it was the upgrade to tsc 4, but the output from tsc 3 and the output from tsc 4 both contain the broken line I think this has likely always been like this, but because we never had metapackages that had real code before we never noticed. The failure is only triggered if you install the instrumentation and try to import it without having the module being instrumented installed. I think this dependency solution is a stopgap. I think the real fix might be to not import the instrumented module in the instrumentation package. |
This is happening not only with metapackage try import just any package it will not compile unless you add a types. And you have to add types into main because if you don't then your final consumer / user of yr package will hit exactly the same error. |
There is no reason to have |
Can you change the title since this actually happens with older versions of typescript too (i checked) |
I tried to reproduce this but failed. Not sure what differs from my setup compared to yours but I see also no difference between typescript 3 and 4. |
ok, can reproduce. Reason why I haven't seen the problem before is that I did tsc --init
tsc -p . The generated tsconfig.json includes |
Now that we can reliably repro, do we think each plugin should declare the types package as a dependency, or should the metapackage declare them all? I would say the metapackage probably. |
having this on each package will be working correctly in each case, the meta will receive "fixed" package automatically then. Or any other meta package that any 3rd party might already have |
I think that's fair. I dont have a strong opinion each way. I see you deleted your branch or I was about to reopen this PR |
it had conflicts anyway |
I think we should put it into each package. But I still think we should not pin the versions instead use An I still think we should aim mid term to get rid of "leaking" such dev dependencies. |
I agree here. We should be able to move all of the types we need into our packages directly instead of depending on them. It's a painful process but it removes this dependency issue. |
At least in most cases we leak only at one place, the protected I don't think the base class actually needs the types. I have not tried yet but I think if we return |
Because of upgrading to ts v4 the types dependency needs to be now a part of main dependency, otherwise there is an error during installation for example
We need to make a patch release asap